'use strict';
import React, { StrictMode, } from "react"
import ReactDOM, { hydrateRoot } from "react-dom/client";
import { BrowserRouter } from "react-router-dom";
import { getClientStore } from '../src/store/store'
import { Provider } from 'react-redux'
import App from '../src/app'


// 客户端入口
const container = document.getElementById("root");

const pages = <Provider store={getClientStore()}>
  <BrowserRouter>
    <App />
  </BrowserRouter>
</Provider>

if (window.__context) {
  // ssr的时候需要注水
  // 需要使用react的hydrate实现注水 监听dom交互即可
  hydrateRoot(container, pages)
}
else {
  // csr的时候客户端不需要注水，正常渲染即可，不然会到导致客户端和服务端不一致而报错
  ReactDOM
    .createRoot(container)
    .render(<StrictMode>{pages}</StrictMode>);
}


